package principle.singleResponsibility;

/**
 * 单一职责原则
 * @author shkstart
 * @create ${year}-${month}-${day}-${time}
 */
public class responsibility {
    public static void main(String[] args) {
//        vehicle vehicle = new vehicle();
        loadVehicle loadVehicle = new loadVehicle();
        loadVehicle.run("摩托");
        waterVehicle waterVehicle = new waterVehicle();
        waterVehicle.run("潜艇");
        airVehicle airVehicle = new airVehicle();
        airVehicle.run("飞机");
    }
}
//交通工具类
//方式一的run方法违法单一职责
//解决方案，根据不同的运行方式写不同的类
class vehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在公路上运行");
    }
}